package com.luntan.school.service.impl;

import com.luntan.school.dao.Page;
import com.luntan.school.dao.PostsDao;
import com.luntan.school.dao.impl.PostsDaoImpl;
import com.luntan.school.service.Posts;
import com.luntan.school.service.PostsService;

import java.util.List;
import java.util.Map;
public class PostsServiceImpl implements PostsService {
    private PostsDao postsDao = new PostsDaoImpl();

    @Override
    public List<Posts> getPostsByCategory(Integer categoryId) {
        return postsDao.getPostsByCategory(categoryId);
    }

    @Override
    public List<Posts> getPostsByTag(Integer tagId) {
        return postsDao.getPostsByTag(tagId);
    }

    @Override
    public List<Posts> getStickPosts(int limit) {
        return postsDao.getStickPosts(limit);
    }

    @Override
    public List<Posts> getAllPosts() {
        return postsDao.getAllPosts();
    }

    @Override
    public Integer addPosts(Posts posts) {
        return postsDao.addPosts(posts);
    }

    @Override
    public void updatePosts(Posts posts) {
        postsDao.updatePosts(posts);
    }

    @Override
    public Posts getPostsById(int postsId) {
        return postsDao.getPostsById(postsId);
    }

    @Override
    public List<Posts> getHotPosts() {
        return postsDao.getHotPosts();
    }

    @Override
    public List<Posts> getRecommendedPosts(int postsId) {
        /**推荐算法说明：
        （1）使用随机推荐，并且限制为5条
        （2）暂未使用新闻自身的标题、标签、内容等信息（在实际中可使用ES内容检索及AI推荐算法，可自行研究）**/
        return postsDao.getRecommendedPosts(postsId);
    }

    @Override
    public void updateClickCount(int postsId) {
        postsDao.updateClickCount(postsId);
    }

    @Override
    public List<Map<String, Object>> statPostsCountByCategory() {
        return postsDao.statPostsCountByCategory();
    }

    @Override
    public List<Map<String, Object>> statPostsCountByTag() {
        return postsDao.statPostsCountByTag();
    }

    @Override
    public List<Map<String, Object>> statPostsCommentCountByDate() {
        return postsDao.statPostsCommentCountByDate();
    }

    @Override
    public List<Map<String, Object>> statPostsCommentCountByUser() {
        return postsDao.statPostsCommentCountByUser();
    }

    @Override
    public Page<Posts> getPagedPosts(int pageNumer, int pageSize, String key) {
        return postsDao.getPagedPosts(pageNumer, pageSize, key);
    }

}
